﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.AGIL;


  /// <summary>
  /// Condition 的引用。
  /// </summary>
  public class ConditionRef:LabelRef
  {
    #region Statics
    public new static ConditionRef it()
    {
      return new ConditionRef();
    }
    public static ConditionRef of(Conditions? cond, string identifier)
    {
      return new ConditionRef(cond,identifier);
    }
    #endregion
    #region Fields
    protected Conditions? cond = null;
    #endregion
    #region Properties
    public virtual Conditions? Condition
    {
      get
      {
        return this.cond;
      }
      set
      {
        this.cond = value;
      }
    }

    public virtual bool HasCondition
    {
      get
      {
        return this.cond != null;
      }
    }
    #endregion
    #region Constructors
    public ConditionRef()
      : base() 
    {
    }
    public ConditionRef(Conditions? cond, string identifier)
      : base(identifier)
    {
      this.cond = cond;
    }
    #endregion
    #region Methods
    public override string ToString()
    {
      return (this.HasCondition && this.Condition!= Conditions.Always)?
        string.Format("{0} @ {1}", this.Identifier, this.Condition) :
        string.Format("{0}", this.Identifier);
    }
    #endregion
  }
}
